//
//  NextViewController.m
//  06-UINavigation
//
//  Created by dllo on 16/7/21.
//  Copyright © 2016年 YMJ. All rights reserved.
//

#import "NextViewController.h"
#import "ViewController.h"
@interface NextViewController ()

@end

@implementation NextViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor brownColor];
     NSLog(@"子控制器%@",self.navigationController.viewControllers);
     NSLog(@"当前控制器%@",self.navigationController.visibleViewController);
    UIButton *bu = [UIButton buttonWithType:UIButtonTypeCustom];
    bu.backgroundColor = [UIColor colorWithRed:1.000 green:0.128 blue:0.050 alpha:1.000];
    bu.frame = CGRectMake(0, 0, 100, 50);
    bu.layer.cornerRadius = 10;
    bu.layer.masksToBounds = YES;
    [self.view addSubview:bu];
    [bu addTarget:self action:@selector(pop) forControlEvents:UIControlEventTouchUpInside];


}
- (void)pop {
    // 返回之前控制器
    [self.navigationController popViewControllerAnimated:YES];
    // 返回指定控制器
    [self.navigationController popToViewController:[ViewController new] animated:YES];
    // 返回根控制器
    [self.navigationController popToRootViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
